// 模板状态 0:正常 1:停用
const TemplateStatusDict = [{value:'0', title:"正常"},{value:'1', title:"停用"}]

// 模板类型 00:BackEndMgmt 01:BusinessWeb
const TemplateTypeDict = [{value:'00', title:"BackEndMgmt"},{value:'01', title:"BusinessWeb"}]


export const enum DictType {
	// 模板状态
	TemplateStatus = 'TemplateStatus',
	//模板类型
	TemplateType = 'TemplateType'
}

// 获取字典Label
const getDictLabel = (dictList: any[], dictValue: string) => {
	const val = dictList.find((element: any) => element.value === dictValue + '')
	if (val) {
		return val.title
	} else {
		return dictValue
	}
}

export const getDictTitle = (dictType: string, value: string): string => {
	var label = ''
	if (dictType == DictType.TemplateStatus) {
		label =  getDictLabel(TemplateStatusDict, value)

	} else if (dictType == DictType.TemplateType) {
		label =  getDictLabel(TemplateTypeDict, value)

	} 

	const result = `<span class="el-tag">${label}</span>&nbsp;`
	return result
	
}

export const getDictOptions = (dictType: string): string => {
	let dataDict = TemplateStatusDict

	if (dictType == DictType.TemplateStatus) {
		dataDict = TemplateStatusDict

	} else if (dictType == DictType.TemplateType) {
		dataDict = TemplateTypeDict
	} 

	console.log(dataDict)

	let result = ''
	dataDict.forEach((dictItem:any) => {
		result += '<el-option value="' + dictItem.value + '" label="' + dictItem.title + '"></el-option>'
		console.log(result)
	})

	return result
	
}